class MyCircularQueue {
    public int[] arr;
    public int first;
    public int last;
    public MyCircularQueue(int k) {
        arr = new int[k + 1];
    }
    
    public boolean enQueue(int value) {
        if(isFull()) {
            return false;
        }
        arr[last] = value;
        last = (last+1)%arr.length;
        return true;
    }
    
    public boolean deQueue() {
        if(isEmpty()) {
            return false;
        }
        first = (first+1) % arr.length;
        return true;
    }
    
    public int Front() {
        if(isEmpty()) {
            return -1;
        }
        return arr[first];
    }
    
    public int Rear() {
        if(isEmpty()) {
            return -1;
        }
        if(last == 0) {
            return arr[arr.length - 1];
        }
        return arr[last - 1];
    }
    
    public boolean isEmpty() {
        return first == last;
    }
    
    public boolean isFull() {
        return (last+1)%arr.length == first;
    }
}
